﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Chowpoo.Sql;
using CourseSystem.Core.Util;

namespace CourseSystem.Core.Entities
{
    [Table(Name = "Examination")]
    public class ExaminationInfo : IDetach
    {
        public ExaminationInfo()
        {
            Detach();
        }
        #region Model
        private int _id;
        private string _title = "";
        private int _type = 0;
        private DateTime _addtime = DateTime.Now;
        private DateTime _endtime = DateTime.Now;
        private bool _istimelimit = false;
        private int _sectionid = 0;
        private int _score = 0;
        private int _status = 0;
        private int _questiontype = 0;
        private int _limittime = 60;
        private int _yearid = 0;
        private int _classid = 0;
        private DateTime _starttime = DateTime.Now;
        private EntityRef<SectionInfo> _sectionInfo;

        [System.Data.Linq.Mapping.Association(Storage = "_sectionInfo", ThisKey = "SectionId", OtherKey = "Id", IsForeignKey = true)]
        [XmlIgnore]
        public SectionInfo SectionInfo
        {
            get { return _sectionInfo.Entity; }
            set { _sectionInfo.Entity = value; }
        }


        private EntitySet<ExaminationItemInfo> _examinationItemInfo;

        [System.Data.Linq.Mapping.Association(Storage = "_examinationItemInfo", ThisKey = "Id", OtherKey = "Eid")]
        public EntitySet<ExaminationItemInfo> ExaminationItemInfo
        {
            get { return this._examinationItemInfo; }
            set { this._examinationItemInfo.Assign(value); }
        }

        private EntitySet<ExaminationSummaryInfo> _examSummaryInfo;

        [System.Data.Linq.Mapping.Association(Storage = "_examSummaryInfo", ThisKey = "Id", OtherKey = "Eid")]
        public EntitySet<ExaminationSummaryInfo> ExamSummaryInfo
        {
            get { return this._examSummaryInfo; }
            set { this._examSummaryInfo.Assign(value); }
        }

        private EntitySet<ExamStatusInfo> _examStatusInfo;

        [System.Data.Linq.Mapping.Association(Storage = "_examStatusInfo", ThisKey = "Id", OtherKey = "Eid")]
        public EntitySet<ExamStatusInfo> ExamStatusInfo
        {
            get { return this._examStatusInfo; }
            set { this._examStatusInfo.Assign(value); }
        }

        private EntitySet<ExamAnswerInfo> _examAnswerInfo;

        [System.Data.Linq.Mapping.Association(Storage = "_examAnswerInfo", ThisKey = "Id", OtherKey = "Eid")]
        public EntitySet<ExamAnswerInfo> ExamAnswerInfo
        {
            get { return this._examAnswerInfo; }
            set { this._examAnswerInfo.Assign(value); }
        }

        private EntityRef<ClassInfo> _classInfo;

        [System.Data.Linq.Mapping.Association(Storage = "_classInfo", ThisKey = "ClassId", OtherKey = "Id", IsForeignKey = true)]
        [XmlIgnore]
        public ClassInfo ClassInfo
        {
            get { return _classInfo.Entity; }
            set { _classInfo.Entity = value; }
        }

        private EntityRef<GradeYearInfo> _gradeYearInfo;

        [System.Data.Linq.Mapping.Association(Storage = "_gradeYearInfo", ThisKey = "YearId", OtherKey = "Id", IsForeignKey = true)]
        [XmlIgnore]
        public GradeYearInfo GradeYearInfo
        {
            get { return _gradeYearInfo.Entity; }
            set { _gradeYearInfo.Entity = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        [Column(IsDbGenerated = true, IsPrimaryKey = true, IsVersion = true)]
        public int Id
        {
            set { _id = value; }
            get { return _id; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        [DisplayName("正在设置")]
        public string Title
        {
            set { _title = value; }
            get { return _title; }
        }
        /// <summary>
        /// 0章节练习1章节作业2课程练习3课程作业4考试
        /// </summary>
        [Column]
        public int Type
        {
            set { _type = value; }
            get { return _type; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public DateTime AddTime
        {
            set { _addtime = value; }
            get { return _addtime; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        [DisplayName("提交有效期止")]
        public DateTime EndTime
        {
            set { _endtime = value; }
            get { return _endtime; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public bool IsTimeLimit
        {
            set { _istimelimit = value; }
            get { return _istimelimit; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int SectionId
        {
            set { _sectionid = value; }
            get { return _sectionid; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int Score
        {
            set { _score = value; }
            get { return _score; }
        }
        /// <summary>
        /// 0未发布1发布
        /// </summary>
        [Column]
        public int Status
        {
            set { _status = value; }
            get { return _status; }
        }
        /// <summary>
        /// 0无乱序1仅实体乱序2仅答案乱序3试题和答案均乱序
        /// </summary>
        [Column]
        public int QuestionType
        {
            set { _questiontype = value; }
            get { return _questiontype; }
        }
        /// <summary>
        /// 限制做题时间
        /// </summary>
        [Column]
        [DisplayName("做题时间")]
        public int LimitTime
        {
            set { _limittime = value; }
            get { return _limittime; }
        }

        /// <summary>
        /// 
        /// </summary>
        [Column]
        [DisplayName("班别")]
        public int ClassId
        {
            set { _classid = value; }
            get { return _classid; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        [DisplayName("提交有效期起")]
        public DateTime StartTime
        {
            set { _starttime = value; }
            get { return _starttime; }
        }

        /// <summary>
        /// 
        /// </summary>
        [Column]
        [DisplayName("年级")]
        public int YearId
        {
            set { _yearid = value; }
            get { return _yearid; }
        }


        public int CollegeIdFake { get; set; }

        public int DepartmentIdFake { get; set; }

        public int SubjectIdFake { get; set; }
        #endregion Model

        public void Detach()
        {
            _sectionInfo = default(EntityRef<SectionInfo>);
            _examinationItemInfo = new EntitySet<ExaminationItemInfo>();
            _examSummaryInfo = new EntitySet<ExaminationSummaryInfo>();
            _examStatusInfo = new EntitySet<ExamStatusInfo>();
            _examAnswerInfo = new EntitySet<ExamAnswerInfo>();
            this._classInfo = default(EntityRef<ClassInfo>);
            this._gradeYearInfo = default(EntityRef<GradeYearInfo>);
        }
    }
}
